package com.vincent.kdp.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.vincent.kdp.R;
import com.vincent.kdp.bean.RepaireSpeedBean;

import java.util.List;

/**
 * Created by jingjing on 2017/3/15.
 */

public class RepairSpeedAdapter extends RecyclerView.Adapter<RepairSpeedAdapter.MyHolder>{

    private Context context;
    private List<RepaireSpeedBean.DataBean> data;

    public RepairSpeedAdapter(Context context,List<RepaireSpeedBean.DataBean> data){
        this.context=context;
        this.data=data;
    }
    @Override
    public RepairSpeedAdapter.MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.repaire_speed_adapter,parent,false);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        holder.currentDepart.setText(data.get(position).getDepartment());
        //0：未完成 1：已完成 2：维修失败 3：转移厂家
        int flag=data.get(position).getFlowStatus();
        switch (flag){
            case 0:
                holder.speed.setText("未完成");
                break;
            case 1:
                holder.speed.setText("已完成");
                break;
            case 2:
                holder.speed.setText("维修失败");
                break;
            case 3:
                holder.speed.setText("转移厂家");
                break;
        }
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    class MyHolder extends ViewHolder{
        TextView currentDepart;
        TextView speed;

        public MyHolder(View itemView) {
            super(itemView);
            currentDepart= (TextView) itemView.findViewById(R.id.current_depart);
            speed= (TextView) itemView.findViewById(R.id.speed);
        }
    }
}
